/*     */ package com.qmsk.business.info.timeRemind;
/*     */ 
/*     */ import com.qmsk.business.store.groupdictrule.dao.GroupDictRuleDAO;
/*     */ import com.qmsk.business.store.specialdictrule.dao.SpecialDictRuleDAO;
/*     */ import com.qmsk.business.store.storedRule.dao.StoredRuleDao;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Calendar;
/*     */ import java.util.Date;
/*     */ import java.util.Timer;
/*     */ import java.util.TimerTask;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class RemindGenerator extends TimerTask
/*     */ {
/*  28 */   private static final Logger logger = Logger.getLogger(RemindGenerator.class);
/*     */ 
/*     */   public void run() {
/*  31 */     logger.info("timer begin");
/*  32 */     int n = 0;
/*  33 */     StoredRuleDao str = new StoredRuleDao();
/*  34 */     n = updateStoreRuleStatus(str);
/*  35 */     if (n > 0)
/*  36 */       logger.info("StoredRuleDao udpate success");
/*  37 */     else if (n < 0) {
/*  38 */       logger.info("StoredRuleDao update lose");
/*     */     }
/*  40 */     n = 0;
/*  41 */     SpecialDictRuleDAO spdr = new SpecialDictRuleDAO();
/*  42 */     n = updateSpecialDictRuleStatus(spdr);
/*  43 */     if (n > 0)
/*  44 */       logger.info("SpecialDictRuleDAO udpate success");
/*  45 */     else if (n < 0) {
/*  46 */       logger.info("SpecialDictRuleDAO update lose");
/*     */     }
/*  48 */     n = 0;
/*  49 */     GroupDictRuleDAO grp = new GroupDictRuleDAO();
/*  50 */     n = updateGroupDictRuleStatus(grp);
/*  51 */     if (n > 0)
/*  52 */       logger.info("GroupDictRuleDAO udpate success");
/*  53 */     else if (n < 0) {
/*  54 */       logger.info("GroupDictRuleDAO update lose");
/*     */     }
/*  56 */     logger.info("timer end");
/*     */   }
/*     */ 
/*     */   public int updateStoreRuleStatus(StoredRuleDao str) {
/*  60 */     int n = 0;
/*     */     try {
/*  62 */       n = str.updateStoreRuleStatus();
/*  63 */       if (n > 0) {
/*  64 */         DbConnection.commit();
/*  65 */         logger.info("StoredRuleDao  There is failure data ");
/*  66 */         return n;
/*     */       }
/*  68 */       DbConnection.rollback();
/*  69 */       logger.info("StoredRuleDao  There is failure data update error ");
/*  70 */       return n;
/*     */     }
/*     */     catch (SQLException e) {
/*  73 */       logger.error(e);
/*  74 */       DbConnection.rollback();
/*  75 */       logger.info("StoredRuleDao  There is failure data update error "); }
/*  76 */     return n;
/*     */   }
/*     */ 
/*     */   public int updateSpecialDictRuleStatus(SpecialDictRuleDAO spdr)
/*     */   {
/*  81 */     int n = 0;
/*     */     try {
/*  83 */       n = spdr.updateSpecialDictRuleStatus();
/*  84 */       if (n > 0) {
/*  85 */         DbConnection.commit();
/*  86 */         logger.info("SpecialDictRuleDAO  There is failure data ");
/*  87 */         return n;
/*     */       }
/*  89 */       DbConnection.rollback();
/*  90 */       logger.info("SpecialDictRuleDAO  There is failure data update error ");
/*  91 */       return n;
/*     */     }
/*     */     catch (SQLException e) {
/*  94 */       logger.error(e);
/*  95 */       DbConnection.rollback();
/*  96 */       logger.info("SpecialDictRuleDAO  There is failure data update error "); }
/*  97 */     return n;
/*     */   }
/*     */ 
/*     */   public int updateGroupDictRuleStatus(GroupDictRuleDAO grp)
/*     */   {
/* 102 */     int n = 0;
/*     */     try {
/* 104 */       n = grp.updateGroupDictRuleStatus();
/* 105 */       if (n > 0) {
/* 106 */         DbConnection.commit();
/* 107 */         logger.info("GroupDictRuleDAO  There is failure data ");
/* 108 */         return n;
/*     */       }
/* 110 */       DbConnection.rollback();
/* 111 */       logger.info("GroupDictRuleDAO  There is failure data update error ");
/* 112 */       return n;
/*     */     }
/*     */     catch (SQLException e) {
/* 115 */       logger.error(e);
/* 116 */       DbConnection.rollback();
/* 117 */       logger.info("GroupDictRuleDAO  There is failure data update error "); }
/* 118 */     return n;
/*     */   }
/*     */ 
/*     */   private static Date addDay(Date date, int num)
/*     */   {
/* 160 */     Calendar startDT = Calendar.getInstance();
/* 161 */     startDT.setTime(date);
/* 162 */     startDT.add(5, num);
/* 163 */     return startDT.getTime();
/*     */   }
/*     */ 
/*     */   public void init(int nHour, int nMinute, int nSecond)
/*     */   {
/* 168 */     Calendar calendar = Calendar.getInstance();
/* 169 */     int year = calendar.get(1);
/* 170 */     int month = calendar.get(2);
/* 171 */     int day = calendar.get(5);
/*     */ 
/* 173 */     calendar.set(year, month, day, nHour, nMinute, nSecond);
/* 174 */     Date date = calendar.getTime();
/* 175 */     if (date.before(new Date())) {
/* 176 */       date = addDay(date, 1);
/*     */     }
/*     */ 
/* 181 */     TimerTask task = new RemindGenerator();
/*     */ 
/* 185 */     new Timer().schedule(task, date);
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.timeRemind.RemindGenerator
 * JD-Core Version:    0.5.3
 */